package main

func main() {

	result, err := Sqrt(-1)
	println(result, err.Error())

}

// 实现error接口
type errors struct {
	msg string
}

func (er errors) Error() string {
	return "Error: " + er.msg
}


func Sqrt(f float64) (float64, error) {
	if f < 0 {
		return 0, errors{msg: "Square root of negative number"}
	}
	return f * 2, nil
}
